package sina;

import java.util.List;

public class A implements Runnable{

    private final List<Data> queue;

    public A(List<Data> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        try{
            while (true){
                synchronized (queue){
                    if(queue.isEmpty()){
                        queue.wait();
                        queue.notifyAll();
                    }
                    Data data=queue.remove(0);
                    System.out.println(data.getData());
                }
                Thread.sleep(1000);
            }
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }
}
